﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace lchealthy
{
    public partial class frmPwd : Form
    {
        public frmPwd()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtnew.Text.Trim() == txtnew1.Text.Trim())
            {
                if (userinfo.isadmin)
                {
                    
                        string sql = string.Format("update shopinfo set spwd='{0}' where sid={1} and spwd='{2}'", txtnew.Text.Trim(), userinfo.id, txtold.Text.Trim());
                        int i = DbHelperOleDb.ExecuteSql(sql);
                        if (i == 1)
                            MessageBox.Show("更新成功！");
                        else
                            MessageBox.Show("更新失败！");
                        this.Close();
                   
                }
                else
                {
                    string sql = string.Format("update dietitianinfo set dpwd='{0}' where did={1} and dpwd='{2}'", txtnew.Text.Trim(), userinfo.id, txtold.Text.Trim());
                    int i = DbHelperOleDb.ExecuteSql(sql);
                    if (i == 1)
                        MessageBox.Show("更新成功！");
                    else
                        MessageBox.Show("更新失败！");
                    this.Close();

                }
                
            }
            else
            {
                MessageBox.Show("两次输入的密码不一致！");

            }
        }

        private void frmPwd_Load(object sender, EventArgs e)
        {

        }
    }
}
